package com.yd.mvc.pc.analysisController;

import com.yd.app.service.pc.agreementService.AgreementService;
import com.yd.app.service.pc.analysisService.AnalysisService;
import com.yd.app.util.BusinessException;
import com.yd.domain.business.Agreement;
import com.yd.domain.business.AnalySum;
import com.yd.domain.business.Analysis;
import com.yd.domain.commom.PageModel;
import com.yd.mvc.baseController.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: zy
 * @Desc: 统计分析
 * @Date:  2018/4/24
 * @Param
 */
@RestController
@RequestMapping(value = "/api/analysis")
public class AnalysisController extends BaseController {
    @Autowired
    AnalysisService analysisService;

    /**
     * @Author: zy
     * @Desc: 根据 产品类型查询
     * @Date:  2018/4/24
     * @Param
     */
    @RequestMapping(value = "/analysisByGStyle", method = RequestMethod.POST)
    public AnalySum analysisByGStyle(@RequestBody Analysis a) throws BusinessException {
        AnalySum analySum = null;
        try {
            analySum =analysisService.getSumByGStyle(a) ;
            analySum.setList(analysisService.analysisByGStyle(a));
        } catch (Exception e) {
            throw new BusinessException(500, "根据商品类型统计数据失败");
        }
        return analySum;
    }
    /**
     * @Author: zy
     * @Desc: 根据产品材质进行统计
     * @Date:  2018/4/24
     * @Param
     */
    @RequestMapping(value = "/analysisByType", method = RequestMethod.POST)
    public AnalySum analysisByType(@RequestBody Analysis a) throws BusinessException {
        AnalySum analySum = null;
        try {
            analySum =analysisService.getSumByGStyle(a) ;
            analySum.setList(analysisService.analysisByType(a));
        } catch (Exception e) {
            throw new BusinessException(500, "根据商品材质统计数据失败");
        }
        return analySum;
    }
}
